<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0,maximum-scale=1.0" />
    <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
	<title></title>
	<!-- 发票抬头 -->
</head>
<body>
	<div id="invoiceTitle">
		<div class="addHeader">
			<span class="back"></span>
			<span class="title">发票抬头</span>
		</div>
		<div class="invoCon">
			<div class="inlist">
				<!--<span class="listName">个人</span>-->
				<!--<div class="invoClass">-->
					<!--发票类型-->
					<!--<span class="cate">增值税普通发票</span>-->
				<!--</div>-->
			</div>
		</div>
		<div class="editCon">
			<a href="editInvoice.html" class="edit">编辑发票抬头</a>
			<span class="cancel">取消</span>
		</div>
	</div>
	<div class="mask"></div>
	<script>
        $(function(){
            //验证是否登陆
            var user_id = sessionStorage.getItem('userId');
            if (user_id == null) {
                alert('请先登录！');
                window.location.href = 'login.html';
            }
            sessionStorage.removeItem('invoceId');
            //获取抬头
            getRise();
        });
        //获取抬头
		function getRise()
		{
		    var user_id = sessionStorage.getItem('userId');
            $.ajax({
                url: url() + 'api/Invoice/invoiceHeader',    //请求的url地址
                dataType: "JSON",   //返回格式为json
                async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                type: "POST",   //请求方式
                data: {
                    user_id:user_id,
                },
                success: function (data) {
                    // console.log(data);
                    var html = '';
                    // 请求成功时处理
                    if(data.status==1){
                        html = `
                        		<span class="listName">${data.result.header_name}</span>
								<div class="invoClass">
									发票类型
									<span class="cate">${data.result.invoice_type}</span>
								</div>
                        `;
                        sessionStorage.setItem('invoceId',data.result.id);
                    } else {
                        html = `
                        		<span class="listName">个人</span>
								<div class="invoClass">
									发票类型
									<span class="cate">增值税普通发票</span>
								</div>
                        `;
                        console.log(data);
                    }
                    $('.inlist').html(html);
                }
            });
		}
	</script>
<script type="text/javascript">

	$(".back").click(function(){
		// history.go(-1)
		window.location.href = 'invoice.html';
	})
	$('.invoCon .inlist').on('click',function(){
		$('.editCon').animate({
			height:"2.866rem",
		},200).show()
		$('.mask').animate({
			height:"100%",
		},100).show()
    	
		//点击遮罩层
		$('.mask , .cancel').on('click',function(){
			$('.editCon').animate({
				height:"0",
			},200).hide()
			$('.mask').animate({
				height:"0",
			},100).hide()
		})
	})
</script>
</body>
</html>
